package com.jy.admin.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.jy.admin.db.dao.RewardConfigDao;
import com.jy.admin.db.entity.RewardConfigEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
* User: zxp
* Date: 2023-01-31
* Time: 15:35:05.213
*/

@Repository
public class RewardConfigDaoImpl extends AbstractBaseMapper<RewardConfigEntity> implements RewardConfigDao {

    @Override
    public List<RewardConfigEntity> selectRewardByClientCodeAndBucket(String clientCode, String bucket) {
        HashMap<String, String> params = Maps.newHashMap();
        params.put("clientCode",clientCode);
        params.put("bucket",bucket);
        return getSqlSession().selectList(this.getStatement("selectRewardByClientCodeAndBucket"), params);
    }
    @Override
    public RewardConfigEntity selectRewardOne(String clientCode, String bucket,String targetFinishValue) {
        HashMap<String, String> params = Maps.newHashMap();
        params.put("clientCode",clientCode);
        params.put("bucket",bucket);
        params.put("targetFinishValue",targetFinishValue);
        return getSqlSession().selectOne(this.getStatement("selectRewardOne"), params);
    }

    @Override
    public List<String> selectRewardBucket() {
        return getSqlSession().selectList(this.getStatement("selectRewardBucket"),null);
    }

    @Override
    public void updateReward(String clientCode, String bucket, String targetFinishValue, String target) {
        HashMap<String, String> params = Maps.newHashMap();
        params.put("clientCode",clientCode);
        params.put("bucket",bucket);
        params.put("targetFinishValue",targetFinishValue);
        params.put("target",target);
        getSqlSession().update(this.getStatement("updateReward"), params);

    }
}